#include "processbar.h"

#define FILESIZE (1024*1024*1024) //这里是宏，要小心加括号

void downloud(callback_t con) // 造数据
{
	
	srand(time(NULL) ^ 1023);
	double rate = 0;
	int allloud = 0;
	while (rate < 100)
	{
		usleep(1000);
	    int loud = rand() % (1024 * 50);
		allloud += loud;
		if (allloud > FILESIZE)
		{
			
			allloud = FILESIZE;
			
		}
		rate = ((allloud * 1.0) / FILESIZE) * 100.0;
		con(rate);
		//printf("%lf%%\n", rate);
	}
	
}



 int main()
 {
	
	   downloud(processbar);
       printf("\n");	
	   return 0;
 }
